package com.ruicar.afs.cloud.workflow.api.dto.flowprocess.response;

import com.ruicar.afs.cloud.common.core.enums.AfsEnumUtil;
import com.ruicar.afs.cloud.workflow.api.enums.FLowCmdType;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

@Data
public class FlowCmdBean {
    private String id;
    private int orderId;
    private int cmdType;
    private int state;
    private String cmdDis;
    private String flowId;
    private String taskId;
    private FLowCmdType fLowCmdType;

    public String getCmdDis() {
        return cmdDis.split("-").length > 1 ? (cmdDis.split("-")[1]) : cmdDis;
    }

    private String getCmdPro() {
        return cmdDis.split("-").length > 1 ? (cmdDis.split("-")[0]) : "";
    }

    public FLowCmdType getFLowCmdType() {
        return StringUtils.isEmpty(getCmdPro()) ? null : (FLowCmdType) AfsEnumUtil.getEnum(getCmdPro(), FLowCmdType.class);
    }
}
